﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Nantianmen.EntityFrameworkCore.Migrations.Postgresql
{
    /// <inheritdoc />
    public partial class AddClustersAndRename : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_DestinationModels",
                table: "DestinationModels");

            migrationBuilder.RenameTable(
                name: "DestinationModels",
                newName: "Destinations");

            migrationBuilder.RenameIndex(
                name: "IX_DestinationModels_Address",
                table: "Destinations",
                newName: "IX_Destinations_Address");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Destinations",
                table: "Destinations",
                column: "Id");

            migrationBuilder.CreateTable(
                name: "Clusters",
                columns: table => new
                {
                    Id = table.Column<string>(type: "text", nullable: false),
                    Remark = table.Column<string>(type: "text", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Clusters", x => x.Id);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Clusters");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Destinations",
                table: "Destinations");

            migrationBuilder.RenameTable(
                name: "Destinations",
                newName: "DestinationModels");

            migrationBuilder.RenameIndex(
                name: "IX_Destinations_Address",
                table: "DestinationModels",
                newName: "IX_DestinationModels_Address");

            migrationBuilder.AddPrimaryKey(
                name: "PK_DestinationModels",
                table: "DestinationModels",
                column: "Id");
        }
    }
}
